﻿// -----------------------------------------------------------------------
// <copyright file="ViewModelLocator.cs" company="CompDJ">
//     Copyright (c) CompDJ. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace T4DemoCs.ViewModel
{
    /// <summary>View Model Locator class.</summary>
    public class ViewModelLocator
    {
        /// <summary>Main View Model statc field.</summary>
        private static MainViewModel fieldMainViewModel;

        /// <summary>Initializes a new instance of the ViewModelLocator class.</summary>
        public ViewModelLocator()
        {
        }

        /// <summary>Gets the MainStatic property.</summary>
        public static MainViewModel MainStatic
        {
            get
            {
                if (fieldMainViewModel == null)
                {
                    fieldMainViewModel = new MainViewModel();
                }

                return fieldMainViewModel;
            }
        }

        /// <summary>Gets the Main property.</summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage(
            "Microsoft.Performance",
            "CA1822:MarkMembersAsStatic",
            Justification = "This non-static member is needed for data binding purposes.")]
        public MainViewModel Main
        {
            get
            {
                return MainStatic;
            }
        }

        /// <summary>Cleans up all the resources.</summary>
        public static void Cleanup()
        {
            fieldMainViewModel.Cleanup();
            fieldMainViewModel = null;
        }
    }
}